import request from "@/util/request"
import { API_SITE, API_PREFIX } from "./_prefix"

/**
 * 获取全部用户模板
 */
export const getAllTempUserId = (userId) => {
    //TODO
    return request(`${API_SITE}${API_PREFIX}/${userId}/template`)
}


/**
 * 更新模板
 */
export const updateMaiTemp = (userId,tempName,title,content,sign,tempId) => {
    return request(`${API_SITE}${API_PREFIX}/${userId}/template/update`,{
        method: "POST",
        body: {
          id:tempId,
          userId:userId,
          tempName: tempName,
          mailTitle: title,
          mailContent: content,
          mailSign: sign,
        }
    })
}

/**
 * 新建用户邮件模板
 */
export const createMaiTemp = (userId,tempName,title,content,sign) => {
    return request(`${API_SITE}${API_PREFIX}/${userId}/template`,{
        method: "POST",
        body: {
          tempName: tempName,
          mailTitle: title,
          mailContent: content,
          mailSign: sign,
        }
    })
}

/**
 * 删除用户邮件模板
 */
export const deleteUserMailTemp = (userId, tempId) => {
    return request(`${API_SITE}${API_PREFIX}/${userId}/template/${tempId}/delete`)
}
